import { INCREMENT,DECREMENT } from "../constants/countConstants";
const init={
    count:0
}
export default function countReducer(prevState=init,action) {
    console.log('reducer调用了',prevState,action);
    //接受action对象的type和data
    const {type,data}=action;
    switch (type) {
        case INCREMENT:
            return {...init,count:prevState.count+data}
        case DECREMENT:
            return {...init,count:prevState.count-data}
    }
    return prevState
}